package com.james.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.james.constant.MessageConstant;
import com.james.constant.RedisConstant;
import com.james.constant.SetmealDeleteFileByCheckgroupException;
import com.james.entity.PageResult;
import com.james.entity.QueryPageBean;
import com.james.entity.Result;
import com.james.pojo.Setmeal;
import com.james.service.SetmealService;
import com.james.util.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import redis.clients.jedis.JedisPool;

import java.util.List;
import java.util.UUID;

/**
 * @author ACT
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private SetmealService setmealService;

    @Autowired
    private JedisPool jedisPool;

    @RequestMapping("/getSetmeal")
    public Result getSetmeal() {
        List<Setmeal> list;
        try {
            list = setmealService.findAll();
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
        return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS, list);
    }

    @RequestMapping("/findById")
    public Result findById(int id) {
        Setmeal setmeal;
        try {
            setmeal = setmealService.findById(id);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmeal);
    }
}
